#encoding='gbk'

import unittest
import ddt
from selenium import webdriver
import time

@ddt.ddt
class Test(unittest.TestCase):
    def setUp(self):
        self.driver= webdriver.Chrome(executable_path='D:\\pythonglr\\python\\driver\\chromedriver.exe')
    def tearDown(self):
        self.driver.quit()
    @ddt.data(['光荣之路测试开发培训','自动化测试'],
              ['飞人乔丹','NBA'],
              ['电影','1905.com'])
    @ddt.unpack
    def test_ddt(self,searh_word,expect_key_word):
        self.driver.get('http://sogou.com')
        self.driver.find_element_by_id('query').clear()
        self.driver.find_element_by_id('query').send_keys(searh_word)
        self.driver.find_element_by_id('stb').click()
        time.sleep(3)
        assert expect_key_word in self.driver.page_source,'页面中不存在要查找的关键字'
        pass

if __name__=='__main__':
    unittest.main()